home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / share / snmp / mib2c-data / mfd-interface.m2c < prev    next >
Encoding:
Text File  |  2007-02-07  |  42.0 KB  |  1,368 lines

  1. #############################################################  -*- c -*-
  2. ## generic include for XXX. Do not use directly.
  3. ##
  4. ## $Id: mfd-interface.m2c,v 1.43.2.3 2005/02/25 22:36:22 rstory Exp $
  5. ########################################################################
  6. @if $m2c_mark_boundary == 1@
  7. /** START code generated by $RCSfile: mfd-interface.m2c,v $ $Revision: 1.43.2.3 $ */
  8. @end@
  9. ########################################################################
  10. ##
  11. ########################################################################
  12. @open ${name}_interface.h@
  13. @eval $hack = "Id"@
  14. /*
  15.  * Note: this file originally auto-generated by mib2c using
  16.  *       version $Revision: 1.43.2.3 $ of $RCSfile: mfd-interface.m2c,v $
  17.  *
  18.  * $$hack:$
  19.  */
  20. /** @defgroup interface: Routines to interface to Net-SNMP
  21.  *
  22.  * \warning This code should not be modified, called directly,
  23.  *          or used to interpret functionality. It is subject to
  24.  *          change at any time.
  25.  * 
  26.  * @{
  27.  */
  28. @include m2c-internal-warning.m2i@
  29. ##
  30. @eval $m2c_save = "$name"@
  31. @eval $name = "${name}_INTERFACE"@
  32. @include generic-header-top.m2i@
  33. @eval $name = $m2c_save@
  34.  
  35. #include "${name}.h"
  36.  
  37. /* ********************************************************************
  38.  * Table declarations
  39.  */
  40. @foreach $table table@
  41. @    include m2c_setup_table.m2i@
  42.  
  43. /* PUBLIC interface initialization routine */
  44. void _${context}_initialize_interface(${context}_registration_ptr user_ctx,
  45.                                     u_long flags);
  46.  
  47. @   if $m2c_data_allocate == 1@
  48. @      eval $m2c_tmp = "${context}_data *"@
  49. @      if $m2c_data_init == 1@
  50. @         eval $m2c_tmp = "$m2c_tmp, void *"@
  51. @      @end@
  52. @   elsif $m2c_data_init == 1@
  53. @      eval $m2c_tmp = "void *"@
  54. @   else@
  55. @      eval $m2c_tmp = "void"@
  56. @   end@
  57.     ${context}_rowreq_ctx * ${context}_allocate_rowreq_ctx($m2c_tmp);
  58. void ${context}_release_rowreq_ctx(${context}_rowreq_ctx *rowreq_ctx);
  59.  
  60. int ${context}_index_to_oid(netsnmp_index *oid_idx,
  61.                             ${context}_mib_index *mib_idx);
  62. int ${context}_index_from_oid(netsnmp_index *oid_idx,
  63.                               ${context}_mib_index *mib_idx);
  64.  
  65. /*
  66.  * access to certain internals. use with caution!
  67.  */
  68. void ${context}_valid_columns_set(netsnmp_column_info *vc);
  69.  
  70. @end@ # for each
  71. @eval $m2c_save = "$name"@
  72. @eval $name = "${name}_INTERFACE"@
  73. @include generic-header-bottom.m2i@
  74. @eval $name = $m2c_save@
  75. ########################################################################
  76. ##
  77. @open ${name}_interface.c@
  78. /*
  79.  * Note: this file originally auto-generated by mib2c using
  80.  *       version $Revision: 1.43.2.3 $ of $RCSfile: mfd-interface.m2c,v $ 
  81.  *
  82.  * $$hack:$
  83.  */
  84. @include m2c-internal-warning.m2i@
  85.  
  86. @include generic-source-includes.m2i@
  87.  
  88. #include <net-snmp/library/container.h>
  89.  
  90. #include "${name}_interface.h"
  91.  
  92. @eval $m2c_processing_type = 'i'@
  93. @foreach $table table@
  94. @   include m2c_setup_table.m2i@
  95. @   include details-table.m2i@
  96. ########################################################################
  97. typedef struct ${context}_interface_ctx_s {
  98.  
  99.    netsnmp_container              *container;
  100.    netsnmp_cache                  *cache; /* optional cache */
  101.  
  102.    ${context}_registration_ptr      user_ctx;
  103.    
  104.    netsnmp_table_registration_info  tbl_info;
  105.  
  106.    netsnmp_baby_steps_access_methods access_multiplexer;
  107.  
  108. } ${context}_interface_ctx;
  109.  
  110. static ${context}_interface_ctx ${context}_if_ctx;
  111.  
  112. static void _${context}_container_init(
  113.     ${context}_interface_ctx *if_ctx);
  114.  
  115.  
  116. static Netsnmp_Node_Handler _mfd_${context}_pre_request;
  117. static Netsnmp_Node_Handler _mfd_${context}_post_request;
  118. static Netsnmp_Node_Handler _mfd_${context}_object_lookup;
  119. static Netsnmp_Node_Handler _mfd_${context}_get_values;
  120. @   if $m2c_table_settable@
  121. static Netsnmp_Node_Handler _mfd_${context}_check_objects;
  122. static Netsnmp_Node_Handler _mfd_${context}_undo_setup;
  123. static Netsnmp_Node_Handler _mfd_${context}_set_values;
  124. static Netsnmp_Node_Handler _mfd_${context}_undo_cleanup;
  125. static Netsnmp_Node_Handler _mfd_${context}_undo_values;
  126. static Netsnmp_Node_Handler _mfd_${context}_commit;
  127. static Netsnmp_Node_Handler _mfd_${context}_undo_commit;
  128. @      if $m2c_irreversible_commit == 1@
  129. static Netsnmp_Node_Handler _mfd_${context}_irreversible_commit;
  130. @      end@
  131. @      if $m2c_table_dependencies == 1@
  132. static Netsnmp_Node_Handler _mfd_${context}_check_dependencies;
  133. @      end@
  134.  
  135. NETSNMP_STATIC_INLINE int _${context}_undo_column( ${context}_rowreq_ctx *rowreq_ctx,
  136.                                                    netsnmp_variable_list *var, int column );
  137. @if $m2c_table_row_creation == 1@
  138. NETSNMP_STATIC_INLINE int _${context}_check_indexes(${context}_rowreq_ctx * rowreq_ctx);
  139. @end@
  140.  
  141. @   end@ # writable
  142. @   if ("$m2c_data_context" eq "generated") && (($m2c_undo_embed == 0) || ($m2c_data_allocate == 1))@
  143. ${context}_data *${context}_allocate_data(void);
  144.  
  145. @   end@
  146. /**
  147.  * @internal
  148.  * Initialize the table $context 
  149.  *    (Define its contents and how it's structured)
  150.  */
  151. void
  152. _${context}_initialize_interface(${context}_registration_ptr reg_ptr,  u_long flags)
  153. {
  154.     netsnmp_baby_steps_access_methods *access_multiplexer =
  155.         &${context}_if_ctx.access_multiplexer;
  156.     netsnmp_table_registration_info *tbl_info = &${context}_if_ctx.tbl_info;
  157.     netsnmp_handler_registration *reginfo;
  158.     netsnmp_mib_handler *handler;
  159.     int    mfd_modes = 0;
  160.  
  161.     DEBUGMSGTL(("internal:${context}:_${context}_initialize_interface","called\n"));
  162.  
  163.  
  164.     /*************************************************
  165.      *
  166.      * save interface context for ${context}
  167.      */
  168.     /*
  169.      * Setting up the table's definition
  170.      */
  171.     netsnmp_table_helper_add_indexes(tbl_info,
  172.     @foreach $tabledx index@
  173.                                   $tabledx.type, /** index: $tabledx */
  174.     @end@
  175.                              0);
  176.  
  177.     /*  Define the minimum and maximum accessible columns.  This
  178.         optimizes retrival. */
  179.     tbl_info->min_column = $context.uc_MIN_COL;
  180.     tbl_info->max_column = $context.uc_MAX_COL;
  181.  
  182.     /*
  183.      * save users context
  184.      */
  185.     ${context}_if_ctx.user_ctx = reg_ptr;
  186.  
  187.     /*
  188.      * call data access initialization code
  189.      */
  190.     ${context}_init_data(reg_ptr);
  191.  
  192.     /*
  193.      * set up the container
  194.      */
  195.     _${context}_container_init(&${context}_if_ctx);
  196.     if (NULL == ${context}_if_ctx.container) {
  197.         snmp_log(LOG_ERR,"could not initialize container for ${context}\n");
  198.         return;
  199.     }
  200.     
  201.     /*
  202.      * access_multiplexer: REQUIRED wrapper for get request handling
  203.      */
  204.     access_multiplexer->object_lookup = _mfd_${context}_object_lookup;
  205.     access_multiplexer->get_values = _mfd_${context}_get_values;
  206.  
  207.     /*
  208.      * no wrappers yet
  209.      */
  210.     access_multiplexer->pre_request = _mfd_${context}_pre_request;
  211.     access_multiplexer->post_request = _mfd_${context}_post_request;
  212.  
  213. ##
  214. @   if $m2c_table_settable@
  215.  
  216.     /*
  217.      * REQUIRED wrappers for set request handling
  218.      */
  219.     access_multiplexer->object_syntax_checks = _mfd_${context}_check_objects;
  220.     access_multiplexer->undo_setup = _mfd_${context}_undo_setup;
  221.     access_multiplexer->undo_cleanup = _mfd_${context}_undo_cleanup;
  222.     access_multiplexer->set_values = _mfd_${context}_set_values;
  223.     access_multiplexer->undo_sets = _mfd_${context}_undo_values;
  224.  
  225.     /*
  226.      * no wrappers yet
  227.      */
  228.     access_multiplexer->commit = _mfd_${context}_commit;
  229.     access_multiplexer->undo_commit = _mfd_${context}_undo_commit;
  230. @   if $m2c_irreversible_commit == 1@
  231.     access_multiplexer->irreversible_commit = _mfd_${context}_irreversible_commit;
  232. @   end@
  233. ##
  234. @      if $m2c_table_dependencies == 1@
  235.     
  236.     /*
  237.      * REQUIRED for tables with dependencies
  238.      */
  239.     access_multiplexer->consistency_checks = _mfd_${context}_check_dependencies;
  240. @      end@
  241. @   end@ # writable
  242.  
  243.     /*************************************************
  244.      *
  245.      * Create a registration, save our reg data, register table.
  246.      */
  247.     DEBUGMSGTL(("$name:init_$context",
  248.                 "Registering $context as a mibs-for-dummies table.\n"));         
  249.     handler = netsnmp_baby_steps_access_multiplexer_get(access_multiplexer);
  250.     reginfo = netsnmp_handler_registration_create("${context}", handler,
  251.                                                   ${context}_oid,
  252.                                                   ${context}_oid_size,
  253.                                                   HANDLER_CAN_BABY_STEP |
  254. @if $m2c_table_settable == 1@
  255.                                                   HANDLER_CAN_RWRITE
  256. @else@
  257.                                                   HANDLER_CAN_RONLY
  258. @end@
  259.                                                   );
  260.     if(NULL == reginfo) {
  261.         snmp_log(LOG_ERR,"error registering table ${context}\n");
  262.         return;
  263.     }
  264.     reginfo->my_reg_void = &${context}_if_ctx;
  265.  
  266.     /*************************************************
  267.      *
  268.      * set up baby steps handler, create it and inject it
  269.      */
  270.     if( access_multiplexer->object_lookup )
  271.         mfd_modes |= BABY_STEP_OBJECT_LOOKUP;
  272.     if( access_multiplexer->set_values )
  273.         mfd_modes |= BABY_STEP_SET_VALUES;
  274.     if( access_multiplexer->irreversible_commit )
  275.         mfd_modes |= BABY_STEP_IRREVERSIBLE_COMMIT;
  276.     if( access_multiplexer->object_syntax_checks )
  277.         mfd_modes |= BABY_STEP_CHECK_OBJECT;
  278.  
  279.     if( access_multiplexer->pre_request )
  280.         mfd_modes |= BABY_STEP_PRE_REQUEST;
  281.     if( access_multiplexer->post_request )
  282.         mfd_modes |= BABY_STEP_POST_REQUEST;
  283.     
  284.     if( access_multiplexer->undo_setup )
  285.         mfd_modes |= BABY_STEP_UNDO_SETUP;
  286.     if( access_multiplexer->undo_cleanup )
  287.         mfd_modes |= BABY_STEP_UNDO_CLEANUP;
  288.     if( access_multiplexer->undo_sets )
  289.         mfd_modes |= BABY_STEP_UNDO_SETS;
  290.     
  291.     if( access_multiplexer->row_creation )
  292.         mfd_modes |= BABY_STEP_ROW_CREATE;
  293.     if( access_multiplexer->consistency_checks )
  294.         mfd_modes |= BABY_STEP_CHECK_CONSISTENCY;
  295.     if( access_multiplexer->commit )
  296.         mfd_modes |= BABY_STEP_COMMIT;
  297.     if( access_multiplexer->undo_commit )
  298.         mfd_modes |= BABY_STEP_UNDO_COMMIT;
  299.     
  300.     handler = netsnmp_baby_steps_handler_get(mfd_modes);
  301.     netsnmp_inject_handler(reginfo, handler);
  302.  
  303.     /*************************************************
  304.      *
  305.      * inject row_merge helper with prefix rootoid_len + 2 (entry.col)
  306.      */
  307.     handler = netsnmp_get_row_merge_handler(reginfo->rootoid_len + 2);
  308.     netsnmp_inject_handler(reginfo, handler);
  309.  
  310.     /*************************************************
  311.      *
  312.      * inject container_table helper
  313.      */
  314.     handler =
  315.         netsnmp_container_table_handler_get(tbl_info,
  316.                                             ${context}_if_ctx.container,
  317.                                             TABLE_CONTAINER_KEY_NETSNMP_INDEX);
  318.     netsnmp_inject_handler( reginfo, handler );
  319.  
  320.     /*************************************************
  321.      *
  322.      * inject cache helper
  323.      */
  324.     if(NULL != ${context}_if_ctx.cache) {
  325.         handler = netsnmp_cache_handler_get(${context}_if_ctx.cache);
  326.         netsnmp_inject_handler( reginfo, handler );
  327.     }
  328.  
  329.     /*
  330.      * register table
  331.      */
  332.     netsnmp_register_table(reginfo, tbl_info);
  333. } /* _${context}_initialize_interface */
  334.  
  335. void
  336. ${context}_valid_columns_set(netsnmp_column_info *vc)
  337. {
  338.     ${context}_if_ctx.tbl_info.valid_columns = vc;
  339. } /* ${context}_valid_columns_set */
  340.  
  341. @include generic-table-indexes-to-oid.m2i@
  342. @include generic-table-indexes-from-oid.m2i@
  343.  
  344. ########################################################################
  345. ##
  346. @    if (($m2c_data_allocate == 1) || ($m2c_undo_embed == 0)) && ("$m2c_data_context" eq "generated")@
  347. @        eval $m2c_gda_todo_suppress = 1@ # no todo comments
  348. @        include generic-data-allocate.m2i@ # resets suppress
  349. @    end@
  350. ########################################################################
  351. /* *********************************************************************
  352.  * @internal
  353.  * allocate resources for a ${context}_rowreq_ctx
  354.  */
  355. ${context}_rowreq_ctx *
  356. @if $m2c_data_allocate == 1@
  357. @   eval $m2c_tmp = "${context}_data *data"@
  358. @   if $m2c_data_init == 1@
  359. @     eval $m2c_tmp = "$m2c_tmp, void *user_init_ctx"@
  360. @   end@
  361. @elsif $m2c_data_init == 1@
  362. @   eval $m2c_tmp = "void *user_init_ctx"@
  363. @else@
  364. @   eval $m2c_tmp = "void"@
  365. @end@
  366. ${context}_allocate_rowreq_ctx($m2c_tmp)
  367. {
  368.     ${context}_rowreq_ctx *rowreq_ctx =
  369.                   SNMP_MALLOC_TYPEDEF(${context}_rowreq_ctx);
  370.  
  371.     DEBUGMSGTL(("internal:${context}:${context}_allocate_rowreq_ctx","called\n"));
  372.  
  373.     if(NULL == rowreq_ctx) {
  374.         snmp_log(LOG_ERR,"Couldn't allocate memory for a "
  375.                  "${context}_rowreq_ctx.\n");
  376.     }
  377. @if $m2c_data_allocate == 1@
  378.     else {
  379.         if(NULL != data) {
  380. @   if $m2c_data_transient == 0@
  381.             /*
  382.              * for non-transient data, track when we got data from user
  383.              */
  384.             rowreq_ctx->rowreq_flags |= MFD_ROW_DATA_FROM_USER;
  385. @   end@
  386.             rowreq_ctx->data = data;
  387.         }
  388.         else if (NULL == (rowreq_ctx->data = ${context}_allocate_data())) {
  389.             SNMP_FREE(rowreq_ctx);
  390.             return NULL;
  391.         }
  392.     }
  393.  
  394.     /*
  395.      * undo context will be allocated when needed (in *_undo_setup)
  396.      */
  397. @end@
  398.  
  399.     rowreq_ctx->oid_idx.oids = rowreq_ctx->oid_tmp;
  400.  
  401.     rowreq_ctx->${context}_data_list = NULL;
  402.     rowreq_ctx->${context}_reg = ${context}_if_ctx.user_ctx;
  403.  
  404. @if $m2c_data_init == 1@
  405.     if(SNMPERR_SUCCESS !=
  406.         ${context}_rowreq_ctx_init(rowreq_ctx, user_init_ctx)) {
  407.        ${context}_release_rowreq_ctx(rowreq_ctx);
  408.        rowreq_ctx = NULL;
  409.     }
  410. @end@
  411.  
  412.     return rowreq_ctx;
  413. } /* ${context}_allocate_rowreq_ctx */
  414.  
  415. /*
  416.  * @internal
  417.  * release resources for a ${context}_rowreq_ctx
  418.  */
  419. void
  420. ${context}_release_rowreq_ctx(${context}_rowreq_ctx *rowreq_ctx)
  421. {
  422.     DEBUGMSGTL(("internal:${context}:${context}_release_rowreq_ctx","called\n"));
  423.  
  424.     netsnmp_assert(NULL != rowreq_ctx);
  425.     
  426. @if $m2c_data_init == 1@
  427.     ${context}_rowreq_ctx_cleanup(rowreq_ctx);
  428. @end@
  429.  
  430. @if $m2c_data_allocate == 1@
  431. @   if $m2c_data_transient == 0@
  432.     /*
  433.      * for non-transient data, don't free data we got from the user
  434.      */
  435.     if ((rowreq_ctx->data) &&
  436.         !(rowreq_ctx->rowreq_flags & MFD_ROW_DATA_FROM_USER))
  437. @   else@
  438.     if (rowreq_ctx->data)
  439. @   end@ # // transient
  440.         ${context}_release_data(rowreq_ctx->data);
  441.  
  442. @end@ 
  443. @if $m2c_undo_embed == 0@
  444.     if(rowreq_ctx->undo)
  445.         ${context}_release_data(rowreq_ctx->undo);
  446.  
  447. @end@ 
  448.     /*
  449.      * free index oid pointer
  450.      */
  451.     if(rowreq_ctx->oid_idx.oids != rowreq_ctx->oid_tmp)
  452.         free(rowreq_ctx->oid_idx.oids);
  453.  
  454.     SNMP_FREE(rowreq_ctx);
  455. } /* ${context}_release_rowreq_ctx */
  456.  
  457. ########################################################################
  458. ##
  459. /**
  460.  * @internal
  461.  * wrapper
  462.  */
  463. static int
  464. _mfd_${context}_pre_request(netsnmp_mib_handler *handler,
  465.                             netsnmp_handler_registration *reginfo,
  466.                             netsnmp_agent_request_info *agtreq_info,
  467.                             netsnmp_request_info *requests)
  468. {
  469.     int rc = ${context}_pre_request(${context}_if_ctx.user_ctx);
  470.     if (MFD_SUCCESS != rc) {
  471.         /*
  472.          * nothing we can do about it but log it
  473.          */
  474.         DEBUGMSGTL(("internal:${context}","error %d from "
  475.                     "${context}_pre_request\n", rc));
  476.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  477.     }
  478.     
  479.     return SNMP_ERR_NOERROR;
  480. } /* _mfd_${context}_pre_request */
  481.  
  482. /**
  483.  * @internal
  484.  * wrapper
  485.  */
  486. static int
  487. _mfd_${context}_post_request(netsnmp_mib_handler *handler,
  488.                              netsnmp_handler_registration *reginfo,
  489.                              netsnmp_agent_request_info *agtreq_info,
  490.                              netsnmp_request_info *requests)
  491. {
  492.     ${context}_rowreq_ctx *rowreq_ctx;
  493.     int rc = ${context}_post_request(${context}_if_ctx.user_ctx);
  494.     if (MFD_SUCCESS != rc) {
  495.         /*
  496.          * nothing we can do about it but log it
  497.          */
  498.         DEBUGMSGTL(("internal:${context}","error %d from "
  499.                     "${context}_post_request\n", rc));
  500.     }
  501.     
  502.     /*
  503.      * if there are no errors, check for and handle row creation/deletion
  504.      */
  505.     rc = netsnmp_check_requests_error(requests);
  506.     if ((SNMP_ERR_NOERROR == rc) &&
  507.         (NULL !=
  508.          (rowreq_ctx = netsnmp_container_table_row_extract(requests)))) {
  509.         if (rowreq_ctx->rowreq_flags & MFD_ROW_CREATED) {
  510.             rowreq_ctx->rowreq_flags &= ~MFD_ROW_CREATED;
  511.             CONTAINER_INSERT(${context}_if_ctx.container, rowreq_ctx);
  512.         }
  513.         else if (rowreq_ctx->rowreq_flags & MFD_ROW_DELETED) {
  514.             CONTAINER_REMOVE(${context}_if_ctx.container, rowreq_ctx);
  515.             ${context}_release_rowreq_ctx(rowreq_ctx);
  516.         }
  517.     }
  518.  
  519.     return SNMP_ERR_NOERROR;
  520. } /* _mfd_${context}_post_request */
  521.  
  522. ########################################################################
  523. ##
  524. /**
  525.  * @internal
  526.  * wrapper
  527.  */
  528. static int
  529. _mfd_${context}_object_lookup(netsnmp_mib_handler *handler,
  530.                          netsnmp_handler_registration *reginfo,
  531.                          netsnmp_agent_request_info *agtreq_info,
  532.                          netsnmp_request_info *requests)
  533. {
  534.     ${context}_rowreq_ctx *rowreq_ctx =
  535.                   netsnmp_container_table_row_extract(requests);
  536.     
  537.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_object_lookup","called\n"));
  538.  
  539.     /*
  540.      * get our context from mfd
  541.      * ${context}_interface_ctx *if_ctx =
  542.      *             (${context}_interface_ctx *)reginfo->my_reg_void;
  543.      */
  544.  
  545.     if(NULL == rowreq_ctx) {
  546. @   if $m2c_table_row_creation == 0@
  547.         netsnmp_request_set_error_all(requests, SNMP_ERR_NOCREATION);
  548. @   else@
  549.         int rc = MFD_SUCCESS;
  550.         netsnmp_table_request_info *tblreq_info;
  551.         netsnmp_index oid_idx;
  552.         ${context}_mib_index mib_idx;
  553.  
  554.         tblreq_info = netsnmp_extract_table_info(requests);
  555.         if(NULL == tblreq_info) {
  556.             snmp_log(LOG_ERR, "request had no table info\n");
  557.             return MFD_ERROR;
  558.         }
  559.  
  560.         /*
  561.          * try to parse oid
  562.          */
  563.         oid_idx.oids = tblreq_info->index_oid;
  564.         oid_idx.len = tblreq_info->index_oid_len;
  565.         rc = ${context}_index_from_oid(&oid_idx, &mib_idx);
  566.         if(MFD_SUCCESS != rc) {
  567.             DEBUGMSGT(("$context", "error parsing index\n"));
  568.             netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  569.         }
  570.         else {
  571.             /*
  572.              * allocate new context
  573.              */
  574. @   eval $m2c_tmp = ""@
  575. @   if ($m2c_data_allocate == 1) || ($m2c_data_init == 1)@
  576. @      eval $m2c_tmp = "NULL"@
  577. @      if ($m2c_data_allocate == 1) && ($m2c_data_init == 1)@
  578. @         eval $m2c_tmp = "$m2c_tmp, NULL"@
  579. @      @end@
  580. @   end@
  581.             rowreq_ctx = ${context}_allocate_rowreq_ctx($m2c_tmp);
  582.             if (NULL == rowreq_ctx)
  583.                 return MFD_ERROR; /* msg already logged */
  584.  
  585.             memcpy(&rowreq_ctx->tbl_idx, &mib_idx, sizeof(mib_idx));
  586.  
  587.             /*
  588.              * check indexes
  589.              */
  590.             rc = _${context}_check_indexes(rowreq_ctx);
  591.             if(MFD_SUCCESS != rc) {
  592.                 netsnmp_assert((rc == SNMP_ERR_NOCREATION) ||
  593.                                (rc == SNMP_ERR_INCONSISTENTNAME));
  594.                 netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  595.                 ${context}_release_rowreq_ctx(rowreq_ctx);
  596.             }
  597.             else {
  598.                 rowreq_ctx->rowreq_flags |= MFD_ROW_CREATED;
  599.                 netsnmp_container_table_row_insert(requests, rowreq_ctx);
  600.             }
  601.         }
  602. @   end@ // row creation
  603.     }
  604.     else {
  605.         ${context}_row_prep(rowreq_ctx);
  606.     }
  607.  
  608.     return SNMP_ERR_NOERROR;
  609. } /* _mfd_${context}_object_lookup */
  610.  
  611. ########################################################################
  612. ##
  613. /***********************************************************************
  614.  *
  615.  * GET processing
  616.  *
  617.  ***********************************************************************/
  618. /*
  619.  * @internal
  620.  * Retrieve the value for a particular column
  621.  */
  622. NETSNMP_STATIC_INLINE int
  623. _${context}_get_column( ${context}_rowreq_ctx *rowreq_ctx,
  624.                        netsnmp_variable_list *var, int column )
  625. {
  626.     int rc = SNMPERR_SUCCESS;
  627.     
  628.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_get_column","called\n"));
  629.  
  630.  
  631.     netsnmp_assert(NULL != rowreq_ctx);
  632.  
  633.     switch(column) {
  634. @   foreach $node internalindex@
  635. @      include m2c_setup_node.m2i@
  636. @      if $node.accessible == 1@
  637.  
  638.     /* (INDEX) $m2c_node_summary */
  639.     case COLUMN_$node.uc:
  640.     var->type = $node.type;
  641. @         if $m2c_node_needlength == 1@
  642.     /*
  643.      * NOTE: val_len is in bytes, ${node}_len might not be (e.g. oids)
  644.      */
  645.         if (var->val_len < (rowreq_ctx->tbl_idx.${node}_len *
  646.                             sizeof(rowreq_ctx->tbl_idx.${node}[0]))) {
  647.            var->val.string = malloc(rowreq_ctx->tbl_idx.${node}_len *
  648.                                     sizeof(rowreq_ctx->tbl_idx.${node}[0]));
  649.         }
  650.         var->val_len = rowreq_ctx->tbl_idx.${node}_len * sizeof(rowreq_ctx->tbl_idx.${node}[0]);
  651.         memcpy( var->val.string, rowreq_ctx->tbl_idx.$node, var->val_len );
  652. @         else@
  653.         var->val_len = sizeof($m2c_decl);
  654.         (*var->val.integer) = rowreq_ctx->tbl_idx.$node;
  655. @         end@
  656.         break;
  657. @      end@ ## accessible
  658. @   end@ ## index
  659. @   foreach $node nonindex@
  660. @      include m2c_setup_node.m2i@
  661. @      if $node.accessible == 1@
  662.  
  663.     /* $m2c_node_summary */
  664.     case COLUMN_$node.uc:
  665. @         if $m2c_node_needlength == 0@
  666.     var->val_len = sizeof($m2c_decl);
  667. @         end@
  668.     var->type = $node.type;
  669. rc = ${node}_get(rowreq_ctx, $m2c_node_var_ref );
  670.         break;
  671.  @      end@ # accessible
  672. @   end@ # for each column
  673.  
  674.      default:
  675.          snmp_log(LOG_ERR,"unknown column %d in _${context}_get_column\n", column);
  676.          break;
  677.     }
  678.  
  679.     return rc;
  680. } /* _${context}_get_column */
  681.  
  682. ########################################################################
  683. ##
  684. int
  685. _mfd_${context}_get_values(netsnmp_mib_handler *handler,
  686.                          netsnmp_handler_registration *reginfo,
  687.                          netsnmp_agent_request_info *agtreq_info,
  688.                          netsnmp_request_info *requests)
  689. {
  690.     ${context}_rowreq_ctx *rowreq_ctx =
  691.                   netsnmp_container_table_row_extract(requests);
  692.     netsnmp_table_request_info * tri;
  693.     u_char                     * old_string;
  694.     void                      (*dataFreeHook)(void *);
  695.     int                        rc;
  696.  
  697.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_get_values","called\n"));
  698.  
  699.     netsnmp_assert(NULL != rowreq_ctx);
  700.     
  701.     for(;requests; requests = requests->next) {
  702.         /*
  703.          * save old pointer, so we can free it if replaced
  704.          */
  705.         old_string = requests->requestvb->val.string;
  706.         dataFreeHook = requests->requestvb->dataFreeHook;
  707.         if(NULL == requests->requestvb->val.string) {
  708.             requests->requestvb->val.string = requests->requestvb->buf;
  709.             requests->requestvb->val_len = sizeof(requests->requestvb->buf);
  710.         }
  711.         else if(requests->requestvb->buf == requests->requestvb->val.string) {
  712.             if(requests->requestvb->val_len != sizeof(requests->requestvb->buf))
  713.                 requests->requestvb->val_len = sizeof(requests->requestvb->buf);
  714.         }
  715.  
  716.         /*
  717.          * get column data
  718.          */
  719.         tri = netsnmp_extract_table_info(requests);
  720.         if(NULL == tri)
  721.             continue;
  722.         
  723.         rc = _${context}_get_column(rowreq_ctx, requests->requestvb, tri->colnum);
  724.         if(rc) {
  725.             if(MFD_SKIP == rc) {
  726.                 requests->requestvb->type = ASN_PRIV_RETRY;
  727.                 rc = SNMP_ERR_NOERROR;
  728.             }
  729.         }
  730.         else if (NULL == requests->requestvb->val.string) {
  731.             snmp_log(LOG_ERR,"NULL varbind data pointer!\n");
  732.             rc = SNMP_ERR_GENERR;
  733.         }
  734.         if(rc)
  735.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  736.  
  737.         /*
  738.          * if the buffer wasn't used previously for the old data (i.e. it
  739.          * was allcoated memory)  and the get routine replaced the pointer,
  740.          * we need to free the previous pointer.
  741.          */
  742.         if(old_string && (old_string != requests->requestvb->buf) &&
  743.            (requests->requestvb->val.string != old_string)) {
  744.             if(dataFreeHook)
  745.                 (*dataFreeHook)(old_string);
  746.             else
  747.                 free(old_string);
  748.         }
  749.     } /* for results */
  750.  
  751.     return SNMP_ERR_NOERROR;
  752. } /* _mfd_${context}_get_values */
  753.  
  754. ########################################################################
  755. ##
  756. /***********************************************************************
  757.  *
  758.  * SET processing
  759.  *
  760.  ***********************************************************************/
  761.  
  762. @if $m2c_table_settable == 0@
  763. /*
  764.  * NOT APPLICABLE (per MIB or user setting)
  765.  */
  766. @else@
  767. /*----------------------------------------------------------------------
  768.  *
  769.  * SET: Syntax checks
  770.  *
  771.  *---------------------------------------------------------------------*/
  772. /*
  773.  * @internal
  774.  * Check the syntax for a particular column
  775.  */
  776. NETSNMP_STATIC_INLINE int
  777. _${context}_check_column( ${context}_rowreq_ctx *rowreq_ctx,
  778.                          netsnmp_variable_list *var, int column )
  779. {
  780.     int rc = SNMPERR_SUCCESS;
  781.     
  782.     DEBUGMSGTL(("internal:${context}:_${context}_check_column","called\n"));
  783.  
  784.     netsnmp_assert(NULL != rowreq_ctx);
  785.  
  786.     switch(column) {
  787. @   foreach $node internalindex@
  788. @      include m2c_setup_node.m2i@
  789. @      if $node.settable == 1@
  790.  
  791.     /* (INDEX) $m2c_node_summary */
  792.     case COLUMN_$node.uc:
  793.         return SNMP_ERR_NOTWRITABLE; /* can not change index of active row */
  794.         break;
  795. @      end@ ## settable
  796. @   end@ ## index
  797. @   foreach $node nonindex@
  798. @      include m2c_setup_node.m2i@
  799. @      if $node.settable == 0@
  800. @          next@
  801. @      end@
  802.  
  803.     /* $m2c_node_summary */
  804.     case COLUMN_$node.uc:
  805. @      include node-varbind-validate.m2i@
  806.     if(SNMPERR_SUCCESS == rc) {
  807.         rc = ${node}_check_value( rowreq_ctx, $m2c_node_var_val );
  808.         if((MFD_SUCCESS != rc) && (MFD_NOT_VALID_EVER != rc) &&
  809.            (MFD_NOT_VALID_NOW != rc)) {
  810.             snmp_log(LOG_ERR, "bad rc %d from ${node}_check_value\n", rc);
  811.             rc = SNMP_ERR_GENERR;
  812.         }
  813.     }
  814.         break;
  815. @   end@ # for each nonindex
  816.  
  817.         default: /** We shouldn't get here */
  818.             rc = SNMP_ERR_GENERR;
  819.             snmp_log(LOG_ERR, "unknown column %d in _${context}_check_column\n", column);
  820.     }
  821.  
  822.     return rc;
  823. } /* _${context}_check_column */
  824.  
  825. ##----------------------------------------------------------------------
  826. int
  827. _mfd_${context}_check_objects(netsnmp_mib_handler *handler,
  828.                          netsnmp_handler_registration *reginfo,
  829.                          netsnmp_agent_request_info *agtreq_info,
  830.                          netsnmp_request_info *requests)
  831. {
  832.     ${context}_rowreq_ctx *rowreq_ctx =
  833.                   netsnmp_container_table_row_extract(requests);
  834.     netsnmp_table_request_info * tri;
  835.     int                          rc;
  836.  
  837.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_check_objects","called\n"));
  838.  
  839.     netsnmp_assert(NULL != rowreq_ctx);
  840.     
  841.     for(;requests; requests = requests->next) {
  842.  
  843.         /*
  844.          * get column number from table request info, and check that column
  845.          */
  846.         tri = netsnmp_extract_table_info(requests);
  847.         if(NULL == tri)
  848.             continue;
  849.  
  850.         rc = _${context}_check_column(rowreq_ctx, requests->requestvb, tri->colnum);
  851.         if(rc) {
  852.             netsnmp_request_set_error(requests, SNMP_VALIDATE_ERR(rc));
  853.             break;
  854.         }
  855.  
  856.     } /* for results */
  857.  
  858.     return SNMP_ERR_NOERROR;
  859. } /* _mfd_${context}_check_objects */
  860.  
  861. ##----------------------------------------------------------------------
  862. @if $m2c_table_row_creation == 1@
  863. NETSNMP_STATIC_INLINE int
  864. _${context}_check_indexes(${context}_rowreq_ctx * rowreq_ctx)
  865. {
  866.     int                          rc;
  867.  
  868.     DEBUGMSGTL(("internal:${context}:_${context}_check_indexes","called\n"));
  869.  
  870.     netsnmp_assert(NULL != rowreq_ctx);
  871.  
  872. ##
  873. @if $m2c_table_external_indexes != 0@
  874.     /*
  875.      * check that the corresponding row exists
  876.      */
  877. @   foreach $node externalindex@
  878. @      include m2c_setup_node.m2i@
  879.  
  880.     /* (INDEX) $m2c_node_summary */
  881.     rc = ${context}_${node}_check_index( rowreq_ctx );
  882.     if(MFD_SUCCESS != rc)
  883.         return SNMP_ERR_NOCREATION;
  884. @   end@ # for each nonindex
  885.  
  886. @end@ # external index
  887. @   foreach $node internalindex@
  888. @      include m2c_setup_node.m2i@
  889.  
  890.     /* (INDEX) $m2c_node_summary */
  891.         rc = ${node}_check_index( rowreq_ctx );
  892.        if(MFD_SUCCESS != rc)
  893.            return SNMP_ERR_NOCREATION;
  894. @   end@ # for each internalindex
  895.  
  896.     /*
  897.      * if individual parts look ok, check them as a whole
  898.      */
  899.     return ${context}_validate_index( rowreq_ctx->${context}_reg, rowreq_ctx );
  900. } /* _${context}_check_indexes */
  901. @end@ # $m2c_table_row_creation
  902.  
  903.  
  904. @      if $m2c_table_dependencies == 1@
  905. /*----------------------------------------------------------------------
  906.  *
  907.  * SET: check dependencies
  908.  *
  909.  *---------------------------------------------------------------------*/
  910. /*
  911.  * @internal
  912.  * Check dependencies wrapper
  913.  */
  914. static int
  915. _mfd_${context}_check_dependencies(netsnmp_mib_handler *handler,
  916.                          netsnmp_handler_registration *reginfo,
  917.                          netsnmp_agent_request_info *agtreq_info,
  918.                          netsnmp_request_info *requests)
  919. {
  920.     int                    rc;
  921.     ${context}_rowreq_ctx *rowreq_ctx =
  922.                   netsnmp_container_table_row_extract(requests);
  923.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_check_dependencies","called\n"));
  924.  
  925.     netsnmp_assert(NULL != rowreq_ctx);
  926.  
  927.     rc = ${context}_check_dependencies(rowreq_ctx);
  928.     if(rc){
  929.         DEBUGMSGTL(("verbose:${context}:mfd","error %d from "
  930.                     "${context}_check_dependencies\n", rc));
  931.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  932.     }
  933.  
  934.     return SNMP_ERR_NOERROR;
  935. } /* _mfd_${context}_check_dependencies */
  936.  
  937. @end@ // dependencies
  938. /*----------------------------------------------------------------------
  939.  *
  940.  * SET: Undo setup
  941.  *
  942.  *---------------------------------------------------------------------*/
  943. /*
  944.  * @internal
  945.  * Set the value for a particular column
  946.  */
  947. NETSNMP_STATIC_INLINE int
  948. _${context}_undo_setup_column( ${context}_rowreq_ctx *rowreq_ctx, int column )
  949. {
  950.     int rc = SNMPERR_SUCCESS;
  951.     
  952.     DEBUGMSGTL(("internal:${context}:_${context}_undo_setup_column","called\n"));
  953.  
  954.     netsnmp_assert(NULL != rowreq_ctx);
  955.  
  956.     switch(column) {
  957. @   foreach $node nonindex@
  958. @      include m2c_setup_node.m2i@
  959. @      if $node.settable == 1@
  960.  
  961.     /* $m2c_node_summary */
  962.     case COLUMN_$node.uc:
  963.         rowreq_ctx->column_set_flags |= FLAG_$node.uc;
  964.         rc = ${node}_undo_setup(rowreq_ctx );
  965.         break;
  966.  @      end@ # settable
  967. @   end@ # for each column
  968.  
  969.      default:
  970.          snmp_log(LOG_ERR,"unknown column %d in _${context}_undo_setup_column\n", column);
  971.          break;
  972.     }
  973.  
  974.     return rc;
  975. } /* _${context}_undo_setup_column */
  976.  
  977.  
  978. ##----------------------------------------------------------------------
  979. /**
  980.  * @internal
  981.  * undo setup
  982.  */
  983. int
  984. _mfd_${context}_undo_setup(netsnmp_mib_handler *handler,
  985.                          netsnmp_handler_registration *reginfo,
  986.                          netsnmp_agent_request_info *agtreq_info,
  987.                          netsnmp_request_info *requests)
  988. {
  989.     int                    rc;
  990.     ${context}_rowreq_ctx *rowreq_ctx =
  991.                   netsnmp_container_table_row_extract(requests);
  992.  
  993.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_undo_setup","called\n"));
  994.  
  995.     netsnmp_assert(NULL != rowreq_ctx);
  996.  
  997. @if $m2c_undo_embed == 0@
  998.     /*
  999.      * allocate undo context
  1000.      */
  1001.     rowreq_ctx->undo = ${context}_allocate_data();
  1002.     if(NULL == rowreq_ctx->undo) {
  1003.         /** msg already logged */
  1004.         netsnmp_request_set_error_all(requests, SNMP_ERR_RESOURCEUNAVAILABLE);
  1005.         return SNMP_ERR_NOERROR;
  1006.     }
  1007.  
  1008. @end@
  1009.     /*
  1010.      * row undo setup
  1011.      */
  1012.     rowreq_ctx->column_set_flags = 0;
  1013.     rc = ${context}_undo_setup(rowreq_ctx);
  1014.     if (MFD_SUCCESS != rc)  {
  1015.         DEBUGMSGTL(("verbose:${context}:mfd","error %d from "
  1016.                     "${context}_undo_setup\n", rc));
  1017.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  1018.     }
  1019.     else {
  1020.         /*
  1021.          * column undo setup
  1022.          */
  1023.         netsnmp_table_request_info * tri;
  1024.         for(;requests; requests = requests->next) {
  1025.             /*
  1026.              * set column data
  1027.              */
  1028.             tri = netsnmp_extract_table_info(requests);
  1029.             if(NULL == tri)
  1030.                 continue;
  1031.             
  1032.             rc = _${context}_undo_setup_column(rowreq_ctx, tri->colnum);
  1033.             if(MFD_SUCCESS != rc)  {
  1034.                 DEBUGMSGTL(("verbose:${context}:mfd","error %d from "
  1035.                             "${context}_undo_setup_column\n", rc));
  1036.                 netsnmp_set_request_error(agtreq_info, requests, SNMP_VALIDATE_ERR(rc));
  1037.             }
  1038.         } /* for results */
  1039.     }
  1040.     
  1041.     return SNMP_ERR_NOERROR;
  1042. } /* _mfd_${context}_undo_setup */
  1043.  
  1044. /**
  1045.  * @internal
  1046.  * undo setup
  1047.  */
  1048. int
  1049. _mfd_${context}_undo_cleanup(netsnmp_mib_handler *handler,
  1050.                              netsnmp_handler_registration *reginfo,
  1051.                              netsnmp_agent_request_info *agtreq_info,
  1052.                              netsnmp_request_info *requests)
  1053. {
  1054.     ${context}_rowreq_ctx *rowreq_ctx =
  1055.                   netsnmp_container_table_row_extract(requests);
  1056.     int rc;
  1057.  
  1058.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_undo_cleanup","called\n"));
  1059.  
  1060.     /*
  1061.      * failed row create in early stages has no rowreq_ctx
  1062.      */
  1063.     if (NULL == rowreq_ctx)
  1064.         return MFD_SUCCESS;
  1065.  
  1066.     /*
  1067.      * call user cleanup
  1068.      */
  1069.     rc = ${context}_undo_cleanup(rowreq_ctx);
  1070.     if (MFD_SUCCESS != rc) {
  1071.         /*
  1072.          * nothing we can do about it but log it
  1073.          */
  1074.         DEBUGMSGTL(("verbose:${context}:mfd","error %d from "
  1075.                     "${context}_undo_cleanup\n", rc));
  1076.     }
  1077.  
  1078. @if $m2c_undo_embed == 0@
  1079.     /*
  1080.      * release undo context, if needed
  1081.      */
  1082.     if(rowreq_ctx->undo) {
  1083.          ${context}_release_data(rowreq_ctx->undo);
  1084.          rowreq_ctx->undo = NULL;
  1085.     }
  1086.  
  1087. @end@
  1088.     /*
  1089.      * clear set flags
  1090.      */
  1091.     rowreq_ctx->column_set_flags = 0;
  1092.  
  1093.     return SNMP_ERR_NOERROR;
  1094. } /* _mfd_${context}_undo_cleanup */
  1095.  
  1096. /*----------------------------------------------------------------------
  1097.  *
  1098.  * SET: Set values
  1099.  *
  1100.  *---------------------------------------------------------------------*/
  1101. /*
  1102.  * @internal
  1103.  * Set the value for a particular column
  1104.  */
  1105. NETSNMP_STATIC_INLINE int
  1106. _${context}_set_column( ${context}_rowreq_ctx *rowreq_ctx,
  1107.                        netsnmp_variable_list *var, int column )
  1108. {
  1109.     int rc = SNMPERR_SUCCESS;
  1110.     
  1111.     DEBUGMSGTL(("internal:${context}:_${context}_set_column","called\n"));
  1112.  
  1113.     netsnmp_assert(NULL != rowreq_ctx);
  1114.  
  1115.     switch(column) {
  1116. @   foreach $node nonindex@
  1117. @      include m2c_setup_node.m2i@
  1118. @      if $node.settable == 1@
  1119.  
  1120.     /* $m2c_node_summary */
  1121.     case COLUMN_$node.uc:
  1122. @         if $m2c_node_needlength == 0@
  1123.         if(var->val_len != sizeof($m2c_decl)) {
  1124.             rc = SNMP_ERR_WRONGLENGTH;
  1125.             snmp_log(LOG_ERR,
  1126.                      "varbind size of %d does not match expected size %d\n",
  1127.                      var->val_len, sizeof($m2c_decl));
  1128.             break;
  1129.         }
  1130. @         end@
  1131.         rowreq_ctx->column_set_flags |= FLAG_$node.uc;
  1132.         rc = ${node}_set(rowreq_ctx, $m2c_node_var_val );
  1133.         break;
  1134.  @      end@ # settable
  1135. @   end@ # for each column
  1136.  
  1137.      default:
  1138.          snmp_log(LOG_ERR,"unknown column %d in _${context}_set_column\n", column);
  1139.          break;
  1140.     }
  1141.     
  1142.     return rc;
  1143. } /* _${context}_set_column */
  1144.  
  1145. ########################################################################
  1146. ##
  1147. int
  1148. _mfd_${context}_set_values(netsnmp_mib_handler *handler,
  1149.                          netsnmp_handler_registration *reginfo,
  1150.                          netsnmp_agent_request_info *agtreq_info,
  1151.                          netsnmp_request_info *requests)
  1152. {
  1153.     ${context}_rowreq_ctx *rowreq_ctx =
  1154.                   netsnmp_container_table_row_extract(requests);
  1155.     netsnmp_table_request_info * tri;
  1156.     int                          rc = SNMP_ERR_NOERROR;
  1157.  
  1158.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_set_values","called\n"));
  1159.  
  1160.     netsnmp_assert(NULL != rowreq_ctx);
  1161.     
  1162.     rowreq_ctx->column_set_flags = 0;
  1163.     for(;requests; requests = requests->next) {
  1164.         /*
  1165.          * set column data
  1166.          */
  1167.         tri = netsnmp_extract_table_info(requests);
  1168.         if(NULL == tri)
  1169.             continue;
  1170.         
  1171.         rc = _${context}_set_column(rowreq_ctx,
  1172.                                     requests->requestvb, tri->colnum);
  1173.         if(MFD_SUCCESS != rc)  {
  1174.             DEBUGMSGTL(("verbose:${context}:mfd","error %d from "
  1175.                         "${context}_set_column\n", rc));
  1176.             netsnmp_set_request_error(agtreq_info, requests, SNMP_VALIDATE_ERR(rc));
  1177.         }
  1178.     } /* for results */
  1179.  
  1180.     return SNMP_ERR_NOERROR;
  1181. } /* _mfd_${context}_set_values */
  1182.  
  1183. /*----------------------------------------------------------------------
  1184.  *
  1185.  * SET: commit
  1186.  *
  1187.  *---------------------------------------------------------------------*/
  1188. /**
  1189.  * @internal
  1190.  * commit the values
  1191.  */
  1192. int
  1193. _mfd_${context}_commit(netsnmp_mib_handler *handler,
  1194.                          netsnmp_handler_registration *reginfo,
  1195.                          netsnmp_agent_request_info *agtreq_info,
  1196.                          netsnmp_request_info *requests)
  1197. {
  1198.     int                    rc;
  1199.     ${context}_rowreq_ctx *rowreq_ctx =
  1200.                   netsnmp_container_table_row_extract(requests);
  1201.  
  1202.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_commit","called\n"));
  1203.  
  1204.     netsnmp_assert(NULL != rowreq_ctx);
  1205.     
  1206.     rc = ${context}_commit(rowreq_ctx);
  1207.     if (MFD_SUCCESS != rc) {
  1208.         DEBUGMSGTL(("verbose:${context}:mfd","error %d from "
  1209.                     "${context}_commit\n", rc));
  1210.         netsnmp_request_set_error_all(requests, SNMP_VALIDATE_ERR(rc));
  1211.     }
  1212.  
  1213.     return SNMP_ERR_NOERROR;
  1214. }
  1215.  
  1216. int
  1217. _mfd_${context}_undo_commit(netsnmp_mib_handler *handler,
  1218.                          netsnmp_handler_registration *reginfo,
  1219.                          netsnmp_agent_request_info *agtreq_info,
  1220.                          netsnmp_request_info *requests)
  1221. {
  1222.     int                    rc;
  1223.     ${context}_rowreq_ctx *rowreq_ctx =
  1224.                   netsnmp_container_table_row_extract(requests);
  1225.  
  1226.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_undo_commit","called\n"));
  1227.  
  1228.     netsnmp_assert(NULL != rowreq_ctx);
  1229.  
  1230.     rc = ${context}_undo_commit(rowreq_ctx);
  1231.     if (MFD_SUCCESS != rc) {
  1232.         /*
  1233.          * nothing we can do about it but log it
  1234.          */
  1235.         DEBUGMSGTL(("verbose:${context}:mfd","error %d from "
  1236.                     "${context}_undo_commit\n", rc));
  1237.     }
  1238.  
  1239.     return SNMP_ERR_NOERROR;
  1240. } /* _mfd_${context}_commit */
  1241.  
  1242. /*----------------------------------------------------------------------
  1243.  *
  1244.  * SET: Undo
  1245.  *
  1246.  *---------------------------------------------------------------------*/
  1247. /**
  1248.  * @internal
  1249.  * undo the value for a particular column
  1250.  */
  1251. NETSNMP_STATIC_INLINE int
  1252. _${context}_undo_column( ${context}_rowreq_ctx *rowreq_ctx,
  1253.                        netsnmp_variable_list *var, int column )
  1254. {
  1255.     int rc = SNMPERR_SUCCESS;
  1256.     
  1257.     DEBUGMSGTL(("internal:${context}:_${context}_undo_column","called\n"));
  1258.  
  1259.     netsnmp_assert(NULL != rowreq_ctx);
  1260.  
  1261.     switch(column) {
  1262. @   foreach $node nonindex@
  1263. @      include m2c_setup_node.m2i@
  1264. @      if $node.settable == 1@
  1265.  
  1266.     /* $m2c_node_summary */
  1267.     case COLUMN_$node.uc:
  1268.         rc = ${node}_undo(rowreq_ctx);
  1269.         break;
  1270.  @      end@ # settable
  1271. @   end@ # for each column
  1272.  
  1273.      default:
  1274.          snmp_log(LOG_ERR,"unknown column %d in _${context}_undo_column\n", column);
  1275.          break;
  1276.     }
  1277.  
  1278.     return rc;
  1279. } /* _${context}_undo_column */
  1280.  
  1281. ########################################################################
  1282. ##
  1283. int
  1284. _mfd_${context}_undo_values(netsnmp_mib_handler *handler,
  1285.                          netsnmp_handler_registration *reginfo,
  1286.                          netsnmp_agent_request_info *agtreq_info,
  1287.                          netsnmp_request_info *requests)
  1288. {
  1289.     int                    rc;
  1290.     ${context}_rowreq_ctx *rowreq_ctx =
  1291.                   netsnmp_container_table_row_extract(requests);
  1292.     netsnmp_table_request_info * tri;
  1293.  
  1294.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_undo_values","called\n"));
  1295.  
  1296.     netsnmp_assert(NULL != rowreq_ctx);
  1297.     
  1298.     for(;requests; requests = requests->next) {
  1299.         /*
  1300.          * set column data
  1301.          */
  1302.         tri = netsnmp_extract_table_info(requests);
  1303.         if(NULL == tri)
  1304.             continue;
  1305.         
  1306.         rc = _${context}_undo_column(rowreq_ctx, requests->requestvb,
  1307.                                      tri->colnum);
  1308.         if (MFD_SUCCESS != rc) {
  1309.             /*
  1310.              * nothing we can do about it but log it
  1311.              */
  1312.             DEBUGMSGTL(("verbose:${context}:mfd","error %d from "
  1313.                         "${context}_undo_column\n", rc));
  1314.         }
  1315.     } /* for results */
  1316.  
  1317.     return SNMP_ERR_NOERROR;
  1318. } /* _mfd_${context}_undo_values */
  1319.  
  1320. @   if $m2c_irreversible_commit == 1@
  1321. /*----------------------------------------------------------------------
  1322.  *
  1323.  * SET: irreversible commit
  1324.  *
  1325.  *---------------------------------------------------------------------*/
  1326. /**
  1327.  * @internal
  1328.  * commit irreversible actions
  1329.  */
  1330. int
  1331. _mfd_${context}_irreversible_commit(netsnmp_mib_handler *handler,
  1332.                          netsnmp_handler_registration *reginfo,
  1333.                          netsnmp_agent_request_info *agtreq_info,
  1334.                          netsnmp_request_info *requests)
  1335. {
  1336.     int                    rc;
  1337.     ${context}_rowreq_ctx *rowreq_ctx =
  1338.                   netsnmp_container_table_row_extract(requests);
  1339.     
  1340.     DEBUGMSGTL(("internal:${context}:_mfd_${context}_irreversible:commit","called\n"));
  1341.    
  1342.     netsnmp_assert(NULL != rowreq_ctx);
  1343.     
  1344.     rc = ${context}_irreversible_commit(rowreq_ctx);
  1345.     if (MFD_SUCCESS != rc) {
  1346.         netsnmp_request_set_error_all(requests, SNMP_ERR_COMMITFAILED);
  1347.         DEBUGMSGTL(("verbose:${context}:mfd","error %d from "
  1348.                     "${context}_irreversible_commit\n", rc));
  1349.     }
  1350.     
  1351.     return SNMP_ERR_NOERROR;
  1352. } /* _mfd_${context}_irreversible_commit */
  1353.  
  1354. @end@
  1355. @end@ # settable
  1356. /***********************************************************************
  1357.  *
  1358.  * DATA ACCESS
  1359.  *
  1360.  ***********************************************************************/
  1361. @    include mfd-access-${m2c_table_access}-defines.m2i@
  1362. @end@ # foreach table
  1363. ##
  1364. ########################################################################
  1365. @if $m2c_mark_boundary == 1@
  1366. /** END code generated by $RCSfile: mfd-interface.m2c,v $ $Revision: 1.43.2.3 $ */
  1367. @end@
  1368.